<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        /* 清除浮动 */
        /*
        .float {
            float: left;
        }
        .box p {
            display: flow-root;
        }
        
    
        */

        /*包裹浮动*/
        /*
        .float{
            float:left;
            height: 150px;
            border: 1px solid red;
        }
        .box{
            border: 1px solid black;
        }
        .box{
            display: flow-root;
        }
        */

        /*避免边距塌陷*/

        /*
        .box{
            margin-bottom: 20px;
            background-color: gray;
            display: flow-root;
        }
        .box div{
            margin-bottom: 10px;
            background-color: lightblue;
        }
        
        */



    </style>
</head>

<body>
    <div class="box">
        <div class="float">
            这是一个浮动元素
        </div>
    </div>
</body>

</html>